home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
YERK
/
SUPPLEME
/
MY_STUFF
/
PMENU.EXA
< prev
next >
Wrap
Text File
|
1991-01-01
|
2KB
|
61 lines
\ rfl sample code as popUp menu example
\ because the popup has an associated hmenu, we can't use 'getpmtxt'
0 constant left
1 constant center
-1 constant right
\ simple subclass of rectangle to bring up pmenu
:CLASS popUpRect <super rect
int just
string myName
:M new: new: myName ;M
:M justify: put: just ;M
\ is point x y inside this rectangle?
:M ptIn: { x y -- b } word0 x y pack (abs) call ptInRect i->l ;M
:M print: ( addr len -- ) put: myName 1 1 inset: self
ptr: myName +base size: myName (abs) int: just call textBox
-1 -1 inset: self ;M
:M draw: draw: super get: myName print: self ;M
:M release: release: myName ;M
;CLASS
window MyWind \ instantiate a window
5 pMenu myPMenu \ instantiate a popUpMenu
2 hMenu myHMenu \ instantiate a hierarchical Menu
popUpRect myPRect \ instantiate a rectangle to click in
new: myPRect \ get a handle
left justify: myPRect
20 50 120 68 put: myPRect
\ menu handlers
: one home mitem . mitem get: myPmenu print: myPRect ;
: five home mitem 4+ . mitem get: myHMenu print: myPRect ;
\ this will be executed when the mouse is clicked inside myPRect
\ Could make class popUpRect a bit more intelligent, storing the pMenu
\ as an IVAR...
: popUp where: theMouse ptIn: myPRect IF popUp: myPMenu THEN ;
: drawR -curs 0 tfont 12 tsize draw: myPRect ;
4 'cfas null null drawR popUp actions: myWind
\ get an example of myWind
example: myWind
\ load the menu...make sure it is in the search pathlist.
" Pmenu.txt" getMTxt